package hottargui.domain.standard;

import java.util.Iterator;
import java.util.Vector;

import hottargui.domain.*;

public class StandardBoard implements Board{

	private Vector<ModifiableTile> myBoard;
	private BoardLayoutStrategy _boardLayoutStrategy;

	public StandardBoard(BoardLayoutStrategy boardLayoutStrategy) {
		_boardLayoutStrategy = boardLayoutStrategy;
		myBoard = _boardLayoutStrategy.getBoardLayout();
	}

	public Iterator<? extends Tile> getBoardIterator() {
		return myBoard.iterator();		
	}

	public ModifiableTile getTile( Position p ) {
		return (ModifiableTile) myBoard.get( (p.getRow()*7)+p.getColumn()); 
	}

	public int getRevenue( PlayerColor playerColor ) {

		int revenue = 0;
		Iterator<? extends Tile> i = getBoardIterator();

		while (i.hasNext()) {
			Tile t = i.next();
			if (t.getOwnerColor()==playerColor) {
				revenue += t.getEconomicValue();
			}
		}	   

		return revenue;
	}


}
